package top.zackyoung.ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import top.zackyoung.ssm.dao.DemoDao;
import top.zackyoung.ssm.entity.User;
import top.zackyoung.ssm.entity.UserRole2;
import top.zackyoung.ssm.mapper.DemoMapper;

import java.util.List;
import java.util.Map;

/**
 * @author: ZackYoung
 * @time: 2020/9/9
 */
@Controller
public class DemoController {
    @Autowired
    DemoDao demoDao;

    @Autowired
    DemoMapper demoMapper;
    @RequestMapping("/demo1")
    public ModelAndView demo1(ModelAndView mav){
        List<Map<String, Object>> queryUserList = demoDao.queryUser();
        mav.addObject("queryUserList",queryUserList);
        mav.setViewName("demo");
        return mav;
    }

    @RequestMapping("/demo2")
    @ResponseBody
    public List<Map<String, Object>> demo2(){
        return demoDao.queryUser();
    }

    @RequestMapping("/demo3")
    @ResponseBody
    public List<User> demo3(){
        return demoMapper.queryUser();
    }

    @RequestMapping("/demo4")
    @ResponseBody
    public List<User> demo4(){
        return demoMapper.queryUser2();
    }

    @RequestMapping("/demo5")
    @ResponseBody
    public List<UserRole2> demo5(){
        return demoMapper.queryUserRole();
    }

    @RequestMapping("/demo6")
    @ResponseBody
    public List<UserRole2> demo6(){
        return demoMapper.queryUserRole2();
    }
}
